<?php

if(isset($_POST["loginBtn"])) {
	
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, "http://online.sokker.org/start.php?session=xml"); 
	curl_setopt($ch, CURLOPT_HEADER, FALSE);
	curl_setopt($ch, CURLOPT_POST, 2);
	curl_setopt($ch, CURLOPT_POSTFIELDS,"ilogin=".$_POST["ilogin"]."&ipassword=".$_POST["ipassword"]);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
	$head = curl_exec($ch); 
	
	if(strtolower(substr($head,0,2))=="ok") {
		
        echo "Login corretto<br>";
        
        $ch2 = curl_init(); 
        curl_setopt($ch2, CURLOPT_URL, 'http://online.sokker.org/xml/vars.xml');
        curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE); 
        $xmlFile = curl_exec($ch2); 
		var_dump($xmlFile);
        
        $xml = @simplexml_load_file("http://online.sokker.org/xml/vars.xml");
		
        echo $xml->getName()."<br>";
		foreach($xml->children() as $child) {
			echo $child->getName(). ": " .$child. "<br>";
		}
	}
	else {
		echo "Errore numero " .substr($head, -1);
	}
}

else {
?>
<form id="loginFrm" method="post" action="">
	Login: <input type="text" name="ilogin" value="" size="12">
	Password: <input type="password" name="ipassword" value="" size="12">
	<input type="submit" name="loginBtn" id="loginBtn" value="Submit">
</form>
<?php
}
?>